package com.tuyrt.hi.library.app

import android.app.Application
import com.google.gson.Gson
import com.tuyrt.hi.library.log.HiConsolePrinter
import com.tuyrt.hi.library.log.HiFilePrinter
import com.tuyrt.hi.library.log.HiLogConfig
import com.tuyrt.hi.library.log.HiLogManager
import com.tuyrt.hi.library.util.ActivityManager

/**
 * author: Administrator on 2021/4/27.
 * desc:
 */
class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        HiLogManager.init(
            object : HiLogConfig() {
                override fun injectJsonParser(): JsonParser {
                    return JsonParser { src -> Gson().toJson(src) }
                }

                override fun getGlobalTag(): String {
                    return "MyApplication"
                }

                override fun includeThread(): Boolean {
                    return true
                }

                override fun enable(): Boolean {
                    return true
                }

                override fun stackTraceDepth(): Int {
                    return 5
                }
            }, HiConsolePrinter(),
            HiFilePrinter.getInstance(applicationContext.cacheDir.absolutePath, 0)
        )
        ActivityManager.instance.init(this)
    }
}